$(function () {
  FB.init({
    appId  : fb_app_id,
    frictionlessRequests: true
  });

	$("div.gallery").smoothDivScroll({
		mousewheelScrolling: true,
		manualContinuousScrolling: true,
		visibleHotSpotBackgrounds: "always"
	});

	$('.head_slogan.slides').slides({
		preload: true,
		preloadImage: base_url+'application/images/loader.gif',
		play: 2000,
		pause: 1000,
		hoverPause: false,
		generatePagination:false,
		paginationClass: "pagination_slid"
	});

	$('.opcs_arti .slides').slides({
		preload: true,
		preloadImage: base_url+'application/images/loader.gif',
		play: 5000,
		pause: 2000,
		hoverPause: true,
		paginationClass: "pagination_slid"
	});

	$("body").css("height", "200px");
	setTimeout(function(){
		$("body").css("height", "200px");
	}, 200);

  $('a#fbShare').on('click', function() {
  	var id = $(this).attr('data-id');
    $.getJSON(base_url+"articulos/ajax_get_articulo_info?id="+id,
      function(data){
        console.log(data);
          FB.ui({
            method: 'feed',
            name: data['info']['0']['titulo'],
            caption: data['info']['0']['nombre'],
            description: (data['info']['desc_bloq1'], data['info']['desc_bloq2']),
            link: 'http://www.tiendacapp.com/publico/a/?id=' + id,
            picture: 'http://www.tiendacapp.com/application/images/logo.png',
            },
             function(response) {
            }
          );
    });
  });

  $('a#twShare').on('click', function() {
    var width = 500,
      height = 500,
      xPosition = ($(window).width()-width) / 2,
      yPosition = ($(window).height()-height) / 2,
      url = base_url+"articulos/twitter/?id=" + $(this).attr('data-id');
    var win = window.open(url, 'Compartir Twitter', 'width=' + width +
                           ', height=' + height +
                           ', top=' + yPosition +
                           ', left=' + xPosition);
  });

});

$(window).load(function() {
	$("body").css("height", "200px");
});


function sendMail(){
	var obj = $(".frm_sendamil");
	if (obj.css("display") == 'none'){
		obj.css('display', 'block');
		$("input[type=email]").focus();
	}else{
		obj.css('display', 'none');
	}
}